<%@page import="helpers.DateHelper"%>
<%@page import="entities.User"%>
<%@page import="entities.OwnerDomain"%>
<%@page import="java.util.ArrayList"%>
<%@page import="helpers.UrlHelper"%>
<%@page import="entities.SiteConfig"%>
<%@page import="java.util.TreeMap"%>
<%@page import="java.util.List"%>
<%
	TreeMap check = (TreeMap) request.getAttribute("check");
	String success = (String) request.getAttribute("success");
	SiteConfig siteConfig = (SiteConfig) request.getAttribute("config");
	String image = UrlHelper.getServerUrl(request) + "/blobstore-serve?blob-key=" + siteConfig.getLogo();
	String form = (String) request.getAttribute("form");
	ArrayList<OwnerDomain> vertifyDomain = (ArrayList<OwnerDomain>) request.getAttribute("vertifyDomain");
	ArrayList<OwnerDomain> unvertifyDomain = (ArrayList<OwnerDomain>) request.getAttribute("unvertifyDomain");
	String yoursite = (String) request.getAttribute("yoursite");
	User user = (User) request.getAttribute("user_logged_in");
%>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:include page="/layouts/header.jsp" />

	<script type="text/javascript" src="/js/verify_domain.js"></script>
	
                <div id="leftSideContent">
                	<div class="profilePage clearafter">
                        <div class="left dashboard">
                            <jsp:include page="/elements/menu_profile.jsp" />
                        </div>
                        <div class="right profileContent">
                            <section class="block">
                                <div class="blockContent">      
                                	<% if (vertifyDomain.size() > 0) { %>                              
                                    <h3 class="title">your sites</h3>
                                    <table cellpadding="0" cellspacing="0" width="100%">
                                        <thead>
                                            <tr align="center">
                                                <td>Website</td>
                                                <td>Website&nbsp;status</td>
                                                <td>Updates</td>
                                                <td>Website&nbsp;certificate</td>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        	<%
												for (int i = 0; i < vertifyDomain.size(); i++) {
											%>
                                            <tr>
                                                <td valign="top">
                                                    <h3><a href="/info/<%=vertifyDomain.get(i).getDomain() %>" target="_blank"><%=vertifyDomain.get(i).getDomain() %></a></h3>
                                                    <a href="/profile/edit/title?domain=<%=vertifyDomain.get(i).getDomain() %>">Click to edit site profile title</a>
                                                    <p>Most important page heading for search engine optimization also known as H1</p>
                                                    <a href="/profile/edit/description?domain=<%=vertifyDomain.get(i).getDomain() %>">Click to edit site profile title</a>
                                                    <p>Most important page heading for search engine optimization also known as H1</p>
                                                    <a href="/profile/delete?id=<%=vertifyDomain.get(i).getId()%>">Delete your site</a>
                                                </td>
                                                <td align="center" class="greenColor">
                                                	<a href="/profile/edit/status?domain=<%=vertifyDomain.get(i).getDomain() %>"><%=vertifyDomain.get(i).getActive() == 1 ? "Active" : "Hidden" %></a>
                                                </td>
                                                <td>
                                                    <!-- <a href="#" class="buttonStyle green">Update Statitsics</a> -->
                                                    <p><% 
															if (vertifyDomain.get(i).getIsUpdated() == 0) {
																List<Long> d = DateHelper.coundownFromNow(vertifyDomain.get(i).getLastUpdate());
														%>
															<span>We will review and confirm your content change soon, or this domain will auto next update after:<br /> 
																<strong><%=d.get(0) > 0 ? Long.toString(d.get(0)) : "0" %></strong> days, 
																<strong><%=d.get(1) > 0 ? Long.toString(d.get(1)) : "0" %></strong> hours, 
																<strong><%=d.get(2) > 0 ? Long.toString(d.get(2)) : "0"%></strong> minutes
															</span>
															
															<br />
															<a href="/preview/<%=vertifyDomain.get(i).getDomain()%>">Preview</a><br />
														<% 
															} else {
																List<Long> l = DateHelper.calDistanceTimeToNow(vertifyDomain.get(i).getLastUpdate());
														%>
															<span>Last updated: <br />
																<strong><%=l.get(0) > 0 ? Long.toString(l.get(0)) : "0" %></strong> days, 
																<strong><%=l.get(1) > 0 ? Long.toString(l.get(1)) : "0" %></strong> hours, 
																<strong><%=l.get(2) > 0 ? Long.toString(l.get(2)) : "0"%></strong> minutes
															</span>
														<% } %>
														Only 1 update/day is allowed. <br />
													</p>
                                                    <p>Would you like to have automatic daily updates? Upgrade your website listing to certified by clicking "Start Certification" in the next column.</p>                                                        
                                                </td>
                                                <td align="center">
                                                    <a href="/certificate/<%=vertifyDomain.get(i).getDomain() %>" class="buttonStyle green">Start Certificate</a>
                                                </td>
                                            </tr>
                                            <% } %>
                                        </tbody>
                                    </table>
                                    <% } %>
                                    
                                    <% if (unvertifyDomain.size() > 0) { %>
                                    <h3 class="title">unverified websites</h3>
                                    <ul class="websiteUnverified">
                                    	<%
											for (int i = 0; i < unvertifyDomain.size(); i++) {
										%>
                                        <li class="clearafter">
                                            <h3 class="left"><a href="/profile/verify?domain=<%=unvertifyDomain.get(i).getDomain()%>" class="websiteName"><%=unvertifyDomain.get(i).getDomain() %></a></h3>
                                            <a href="/profile/delete?id=<%=unvertifyDomain.get(i).getId()%>" class="right buttonStyle">Remove website</a>
                                        </li>
                                        <% } %>
                                    </ul>
                                    <% } %>
                                    
                                    <h3 class="title">add your website</h3>
                                    <p>Add your website to immediately get access to the following benefits and features:</p>
                                    <ul class="benefit">
                                        <li>Edit description and owner's quote for your website. Write custom descriptions and get periodically featured on home page in "featured descriptions" block.</li>
                                        <li>Gain up to 4 additional links to your website in the description including custom anchor text. Exceptional free SEO opportunity.</li>
                                        <li>Temporary hide or permanently remove your website from <%=UrlHelper.getDomainServer(request) %></li>
                                        <li>Plus coming soon features: contact info update, tags editor, rss, social and more!</li>
                                    </ul>
                                    <form method="post" action="">
                                        <% if (check.get("yoursite") != null) { %>
											<div class="error"><%=check.get("yoursite")%></div>
										<% } %>
										<input type="text" name="yoursite" value="<%=yoursite == null ? "http://" : "http://" + yoursite %>" />
                                        <button type="submit" class="buttonStyle">Next</button>
                                    </form>                                    
                                </div>
                                <div class="blockShadow"></div>
                            </section>
                        </div>
                    </div>
                </div>
                
                <!-- right content -->
                <jsp:include page="/elements/right.jsp" />
                <!-- end right content -->
                
<jsp:include page="/layouts/footer.jsp" />